options(repos = c(CRAN = "https://cloud.r-project.org"))
if (!require("pak")) install.packages("pak")
pkgs = c(
"sf",
"tidyverse",
"tmap",
"osmextract"
)
pak::pak(pkgs)Prerequisites
1 Course Prerequisites
We assume you are familiar with transport datasets and have basic data analysis skills.
You must have a GitHub account and have saved your username.
We will cover version control concepts in the course.
2 Software Prerequisites
You should bring a laptop with either of the following:
- Option 1: if you’re using a cloud-based development environment:
- A modern web browser (e.g., Chrome, Firefox, Edge).
- A GitHub account (sign up at github.com) and have your username ready.
- Tested out GitHub Codespaces to ensure it works on your machine by opening this link and running the prerequisites code in prerequisites.qmd:
or, for running the code locally:
- Option 2: A laptop with a the necessary software installed, including:
- An IDE such as VS Code (recommended) or RStudio.
- R or Python installed (see below for testing code).
- The
ghcommand-line tool (see cli.github.com for installation and set-up instructions).
3 Recommended Online Courses
To prepare for this course, we recommend watching the following short video:
- Introduction to AI Fluency by Anthropic (Lesson 1, ~5 minutes).
And taking these short but very useful online courses:
- Intro to GitHub (should take less than an hour).
- Communicate using Markdown (should take around 30 minutes or less).
4 Testing your setup
You can test your setup by running the following code in Python or R, either in your local IDE or in GitHub Codespaces. Do so by first creating a new Quarto (.qmd) file, e.g. called test.qmd, and then typing the following into a code chunk with three backticks (located in the top left of your keyboard, just left of the 1 key) to start and end the code chunk and {r} or {python} at the end of the first code chunk to make the code interactive, as follows (update the code as needed):

You should be able to run the code in a GitHub Codespaces with the following link:
Choose either the Python or R code below, depending on which language you prefer to use.
library(tidyverse)
library(sf)The next bit optionally downloads lots of data, so you may want to skip it if you’re just testing your setup.
Code
# Centered on Broadway House, London
broadway_house = stplanr::geo_code("Tothill St, London")
# [1] -0.1302077 51.4996820
study_area = st_point(c(-0.13020, 51.4997)) |>
st_sfc(crs = 4326) |>
st_transform(27700) |>
st_buffer(500) |>
st_transform(4326)
extra_tags = c(
"maxspeed",
"lit",
"cycleway"
)
osm_network = osmextract::oe_get_network(
place = study_area,
boundary = study_area,
boundary_type = "clipsrc",
extra_tags = extra_tags,
mode = "driving"
)# sf::write_sf(osm_network, "osm_network.geojson", delete_dsn = TRUE)
osm_network = sf::read_sf("osm_network.geojson")library(tmap)
tmap_mode("view")
m = tm_shape(osm_network) +
tm_lines("maxspeed")
m